﻿@model KhoaLuan.Models.ApplicationUser
@{
    ViewBag.Title = "Index";
}

<h2 style="color:red;">quản ly User</h2>


<div role="tabpanel">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#edit" aria-controls="edit" role="tab" data-toggle="tab">Web Master Edition</a></li>
        <li role="presentation"><a href="#list" aria-controls="list" role="tab" data-toggle="tab">List of Web Masters</a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="edit">
            <h4>@Html.ValidationSummary()</h4>
            @using (Html.BeginForm("Insert", "User"))
            {
                <div class="form-group">
                    <div>Id</div>
                    @Html.TextBoxFor(r => r.Id, new { @class = "form-control", @readonly = true })
                </div>

                <div class="form-group">
                    <div>User Name</div>
                    @Html.TextBoxFor(r => r.UserName, new { @class = "form-control" })
                </div>

                if (!String.IsNullOrEmpty(Model.UserName))
                {
                    <div class="form-group">
                        <div>Password</div>
                        @Html.Password("Password", "******", new { @class = "form-control" })
                    </div>
                }

                <div class="form-group">
                    <div>New Password</div>
                    @Html.Password("NewPassword1", "", new { @class = "form-control" })
                </div>

                <div class="form-group">
                    <div>Confirm New Password</div>
                    @Html.Password("NewPassword2", "", new { @class = "form-control" })
                </div>

                <div class="form-group">
                    <div></div>
                    <div>
                        <button onclick="form.action='/Admin/User/Insert'" class="btn btn-default">Insert</button>
                        <button onclick="form.action = '/Admin/User/Update'" class="btn btn-default">Update</button>
                        <a href="/Admin/User/Delete/@Model.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        <a href="/Admin/User/Index" class="btn btn-default">Reset</a>
                    </div>
                </div>
            }
        </div>
        <div role="tabpanel" class="tab-pane" id="list">
            <table class="table table-hover">
                <tr>
                    <th>Id</th>
                    <th>Name</th>
                    <th>Password</th>
                    <th></th>
                </tr>
                @foreach (var s in ViewBag.Users)
                {
                    <tr>
                        <td>@s.Id</td>
                        <td>@s.UserName</td>
                        <td>******</td>
                        <td>
                            <a href="/Admin/User/Edit/@s.Id" class="btn btn-default">Edit</a>
                            <a href="/Admin/User/Delete/@s.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        </td>
                    </tr>
                }
            </table>
        </div>
    </div>

</div>

@section scripts{


    <script>
    function Xoa() {
        var ok = confirm("Có chắc chắn xóa mẫu tin có mã  không?");
        if (ok == true) {
            window.location.href = "/Admin/User/Delete/@Model.Id";
        } else {
            return false;
        }
    }
    </script>

}